exports.toTree = (obj) => {
    let asideData = []
    return (function toTreeObj(obj,fn) {
        if (obj.length && typeof obj === "object") {
            obj.forEach(element => {
                if (element.parent === "0") {
                    element.child = []
                    asideData.push(element)
                } else {
                    toTreeObj(element)
                }
            });
        } else {
            asideData.filter(item => {
                if (item.name === obj.parent) {
                    item.child.push(obj)
                }
            })
        } 
        return asideData
    })(obj,this.toTree)
}